//轮播图
var mySwiper = new Swiper ('.swiper-container', {
    loop: true, // 循环模式选项
    autoplay:true,//自动轮播

    // 如果需要分页器
    pagination: {
        el: '.swiper-pagination'
    },

    // 如果需要前进后退按钮
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev'
    }
});



//返回顶部
var kk1 = document.querySelector("#kk1");

var ee1 = document.querySelector("#ee1");


//滚动事件，没触发一次，这个事件就执行一次。
window.onscroll = function(){

    //判断他离顶部的距离
    if (document.documentElement.scrollTop > 300 || document.body.scrollTop > 300){
        kk1.style.display = "block";
    }
    else {
        kk1.style.display = "none";
    }



    if (document.documentElement.scrollTop > 225 || document.body.scrollTop > 225){
        ee1.style.position = "fixed";
        ee1.style.top = "0";
    }else {
        ee1.style.position = "relative";
    }
};

kk1.addEventListener('click',function(){
    //距离顶部的距离为x为0，y为0.
    //window.scrollTo(0,0);


    window.scrollTo({
        top: 0 ,
        behavior: 'smooth'
    })

});

//json数据
new Vue({
    el:"#xxk1",
    data:{
        an:[
            {l:"images/images1/1.jpg",p:"天翼系列",span:"2680.00"},
            {l:"images/images1/2.jpg",p:"臻典系列",span:"4180.00"},
            {l:"images/images1/3.jpg",p:"天翼系列",span:"2580.00"},
            {l:"images/images1/4.jpg",p:"天翼系列",span:"980.00"},
            {l:"images/images1/5.jpg",p:"臻典系列",span:"4180.00"}
        ]
    }
});



new Vue({
    el:"#wn1",
    data:{an:""},
    mounted(){
        axios
            .get('json/json.json')
            .then(response => this.an = response.data.urls)
            .catch(function(error){
                console.log(error);
            })
    }


});

new Vue({
    el:"#wn2",
    data:{an1:""},
    mounted(){
        axios
            .get('json/json.json')
            .then(response => this.an1 = response.data.ul)
            .catch(function(error){
                console.log(error);
            })
    }


});

//选项卡
var span1 = document.querySelectorAll('.main2-2 > span > a');
var div1 = document.querySelectorAll('.main-z > div');
for(var i=0 ; i<span1.length ; i++){
    span1[i].index = i;
    span1[i].addEventListener('click',function(){
        for (var j=0 ; j<span1.length ; j++){
            span1[j].classList.remove("a3");
            div1[j].classList.remove("active1");
        }
        this.classList.add("a3");
        div1[this.index].classList.add("active1");
    })
}

